<?php

class Admin_SupportOnlineController extends Zend_Controller_Action
{

    public function init()
    {
        /* Initialize action controller here */
    }
    
    public function indexAction()
    {
    	$this->_forward('List','Index','News');
    }
    
    public function SupportOnlineAction()
    {
    	$model = new SupportOnline_Model_category();
    	$categories = $model->getCategoryList()->toArray();
    	$form = new Zend_Form();
    }
    
    public function editAction()
    {
    	$username = new SupportOnline_Model_username();
    	$ym = $model->getCategoryList()->toArray();
    	$form = new Zend_Form();
    	
    	$hiddenid = new Zend_Form_Element_Hidden('news_id');
    	
    	$categoryList = new Zend_Form_Element_Select('categories_id');
    	$categoryList->setLabel('Category:');
    	foreach ($categories as $id=>$category)
    		$categoryList->addMultiOption($id,$category['categories_name']);
    	
    	if ($this->getRequest()->isPost())
    	{
    		if ($form->isValid($_POST))
    		{
    			$newsmdl = new Admin_Model_SupportOnline();
    			$newsmdl->updateSupportOnline(
    									$form->getValue('SupportOnline_id'),
    									$form->getValue('SupportOnline_username'),
    									$form->getValue('SupportOnline_ym')
    								);
    			$this->_forward('Index','SupportOnline');
    		}
    	}
    	
    	$newsmodel = new Admin_Model_SupportOnline();
    	$newsid = $this->getRequest()->getParam('id');
    	$this->view->id = $newsid;
    	$news = $SupportOnlinemodel->find($supportonlineid)->current();
    	$form->populate($news->toArray());
    	$this->view->SupportOnline = $Supportonline;
    	$this->view->form = $form;
    }
    
    public function deleteAction()
    {
    	$id = $this->getRequest()->getParam('id');
    	$model = new Admin_Model_SupportOnline();
    	$model->deleteSupportOnline($id);
    	$this->_forward('Index','SupportOnline');
    }
}